﻿using System;
using System.Data.Common;
using System.Linq;
using System.Text;
using Nvigorate.Common;
using Nvigorate.Common.Reflection;

namespace Nvigorate.Data
{
    public class DatabaseProviderFactory
    {
        public static IDatabaseProvider GetProvider(string providerTypeName)
        {
            try
            {
                return (IDatabaseProvider) Activator.CreateInstance(Reflector.GetType(providerTypeName));
            }
            catch (Exception e)
            {
                throw new DataInterfaceException("An exception occurred trying to initialize the DatabaseProvider type {0}. Please ensure the class is spelled correctly and includes the assembly name.", providerTypeName);
            }
        }
    }
}
